package com.sskj.trafficcontrol.config;

import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * Describe：mybaits的分页插件配置类
 */
@Configuration
public class MybaitsLimitPageCfg {
    private static Logger LOGGER = LoggerFactory.getLogger(MybaitsLimitPageCfg.class);
    @Bean
    public PageHelper pageHelper() {
        PageHelper pageHelper = new PageHelper();
        Properties p = new Properties();
        p.setProperty("offsetAsPageNum", "true");
        p.setProperty("rowBoundsWithCount", "true");
        p.setProperty("reasonable", "true");
        pageHelper.setProperties(p);
        LOGGER.info("MybaitsLimitPageCfg pageHelper is starting");
        return pageHelper;
    }
}
